home *** CD-ROM | disk | FTP | other *** search
/ Aminet 48 / Aminet 48 (2002)(GTI - Schatztruhe)[!][Apr 2002].iso / Aminet / text / edit / vim60rt.lha / Vim / vim60 / doc / quickfix.txt < prev    next >
Encoding:
Text File  |  2001-09-26  |  31.0 KB  |  726 lines

  1. *quickfix.txt*  For Vim version 6.0.  Last change: 2001 Sep 21
  2.  
  3.  
  4.           VIM REFERENCE MANUAL    by Bram Moolenaar
  5.  
  6.  
  7. {Vi does not have any of these commands}
  8.  
  9. The quickfix commands are not available when the |+quickfix| feature was
  10. disabled at compile time.
  11.  
  12. This subject is introduced in section |30.1| of the user manual.
  13.  
  14. 1. Using QuickFix commands        |quickfix|
  15. 2. The error window            |quickfix-window|
  16. 3. Selecting a compiler            |compiler-select|
  17. 4. Using more than one list of errors    |quickfix-error-lists|
  18. 5. Using :make                |:make_makeprg|
  19. 6. The error file format        |error-file-format|
  20. 7. The directory stack            |quickfix-directory-stack|
  21. 8. Specific error file formats        |errorformats|
  22.  
  23. =============================================================================
  24. 1. Using QuickFix commands            *quickfix* *Quickfix* *E42*
  25.  
  26. Vim has a special mode to speedup the edit-compile-edit cycle.  This is
  27. inspired by the quickfix option of the Manx's Aztec C compiler on the Amiga.
  28. The idea is to save the error messages from the compiler in a file and use
  29. Vim to jump to the errors one by one.  You can then examine each problem and
  30. fix it, without having to remember all the error messages.
  31.  
  32. If you are using Manx's Aztec C compiler on the Amiga you should do the
  33. following:
  34. - Set the CCEDIT environment variable with the command
  35.     mset "CCEDIT=vim -q"
  36. - Compile with the -qf option.  If the compiler finds any errors, Vim is
  37.   started and the cursor is positioned on the first error.  The error message
  38.   will be displayed on the last line.  You can go to other errors with the
  39.   commands mentioned below.  You can fix the errors and write the file(s).
  40. - If you exit Vim normally the compiler will re-compile the same file.  If you
  41.   exit with the :cq command, the compiler will terminate.  Do this if you
  42.   cannot fix the error, or if another file needs to be compiled first.
  43.  
  44. If you are using another compiler you should save the error messages in a
  45. file and start Vim with "vim -q filename".  An easy way to do this is with
  46. the ":make" command (see below).  The 'errorformat' option should be set to
  47. match the error messages from your compiler (see below).
  48.  
  49. The following commands can be used if you are in QuickFix mode:
  50.  
  51.                             *:cc*
  52. :cc[!] [nr]        Display error [nr].  If [nr] is omitted, the same
  53.             error is displayed again.  Without [!] this doesn't
  54.             work when jumping to another buffer, the current buffer
  55.             has been changed, there is the only window for the
  56.             buffer and both 'hidden' and 'autowrite' are off.
  57.             When jumping to another buffer with [!] any changes to
  58.             the current buffer are lost, unless 'hidden' is set or
  59.             there is another window for this buffer.
  60.             The 'switchbuf' settings are respected when jumping
  61.             to a buffer.
  62.  
  63.                             *:cn* *:cnext*
  64. :[count]cn[ext][!]    Display the [count] next error in the list that
  65.             includes a file name.  If there are no file names at
  66.             all, go to the [count] next error.  See |:cc| for
  67.             [!] and 'switchbuf'.
  68.  
  69. :[count]cN[ext][!]            *:cp* *:cprevious* *:cN* *:cNext*
  70. :[count]cp[revious][!]    Display the [count] previous error in the list that
  71.             includes a file name.  If there are no file names at
  72.             all, go to the [count] previous error.  See |:cc| for
  73.             [!] and 'switchbuf'.
  74.  
  75.                             *:cnf* *:cnfile*
  76. :[count]cnf[ile][!]    Display the first error in the [count] next file in
  77.             the list that includes a file name.  If there are no
  78.             file names at all or if there is no next file, go to
  79.             the [count] next error.  See |:cc| for [!] and
  80.             'switchbuf'.
  81.  
  82.                             *:crewind* *:cr*
  83. :cr[ewind][!] [nr]    Display error [nr].  If [nr] is omitted, the FIRST
  84.             error is displayed.  See |:cc|.
  85.  
  86.                             *:cfirst* *:cfir*
  87. :cfir[st][!] [nr]    Same as ":crewind".
  88.  
  89.                             *:clast* *:cla*
  90. :cla[st][!] [nr]    Display error [nr].  If [nr] is omitted, the LAST
  91.             error is displayed.  See |:cc|.
  92.  
  93.                             *:cq* *:cquit*
  94. :cq[uit]        Quit Vim with an error code, so that the compiler
  95.             will not compile the same file again.
  96.  
  97.                             *:cf* *:cfile*
  98. :cf[ile][!] [errorfile]    Read the error file and jump to the first error.
  99.             This is done automatically when Vim is started with
  100.             the -q option.  You can use this command when you
  101.             keep Vim running while compiling.  If you give the
  102.             name of the errorfile, the 'errorfile' option will
  103.             be set to [errorfile].  See |:cc| for [!].
  104.  
  105.                             *:cl* *:clist*
  106. :cl[ist] [from] [, [to]]
  107.             List all errors that are valid |quickfix-valid|.
  108.             If numbers [from] and/or [to] are given, the respective
  109.             range of errors is listed. A negative number counts
  110.             from the last error backwards, -1 being the last error.
  111.             The 'switchbuf' settings are respected when jumping
  112.             to a buffer.
  113.  
  114. :cl[ist]! [from] [, [to]]
  115.             List all errors.
  116.  
  117.                             *:mak* *:make*
  118. :mak[e][!] [arguments]    1. If the 'autowrite' option is on, write any changed
  119.                buffers
  120.             2. An errorfile name is made from 'makeef'.  If
  121.                'makeef' doesn't contain "##", and a file with this
  122.                name already exists, it is deleted.
  123.             3. The program given with the 'makeprg' option is
  124.                started (default "make") with the optional
  125.                [arguments] and the output is saved in the
  126.                errorfile (for Unix it is also echoed on the
  127.                screen).
  128.             4. The errorfile is read
  129.             5. If [!] is not given the first error is jumped to.
  130.             6. The errorfile is deleted.
  131.             7. You can now move through the errors with commands
  132.                like |:cnext| and |:cprevious|, see above.
  133.             This command does not accept a comment, any "
  134.             characters are considered part of the arguments.
  135.  
  136.                                 *:gr* *:grep*
  137. :gr[ep][!] [arguments]    Just like ":make", but use 'grepprg' instead of
  138.             'makeprg' and 'grepformat' instead of 'errorformat'.
  139.             See |grep|.
  140.             [Unix trivia: The name for the Unix "grep" command
  141.             comes from ":g/re/p", where "re" stands for Regular
  142.             Expression.]
  143.                             *:grepa* *:grepadd*
  144. :grepa[dd][!] [arguments]
  145.             Just like ":grep", but instead of making a new list of
  146.             errors the matches are appended to the current list.
  147.             Example: >
  148.                 :grep nothing %
  149.                 :bufdo grepadd! something %
  150. <            The first command makes a new error list which is
  151.             empty.  The second command executes "grepadd" for each
  152.             listed buffer.  Note the use of ! to avoid that
  153.             ":grepadd" jumps to the first error, which is not
  154.             allowed with |:bufdo|.
  155.  
  156. =============================================================================
  157. 2. The error window                    *quickfix-window*
  158.  
  159.                             *:cope* *:copen*
  160. :cope[n] [height]    Open a window to show the current list of errors.
  161.             When [height] is given, the window becomes that high
  162.             (if there is room).  Otherwise the window is made ten
  163.             lines high.
  164.             The window will contain a special buffer, with
  165.             'buftype' equal to "quickfix".  Don't change this!
  166.             If there already is a quickfix window, it will be made
  167.             the current window.  It is not possible to open a
  168.             second quickfix window.
  169.  
  170.                             *:ccl* *:cclose*
  171. :ccl[ose]        Close the quickfix window.
  172.  
  173.                             *:cw* *:cwindow*
  174. :cw[indow] [height]    Open the quickfix window when there are recognized
  175.             errors.  If the window is already open and there are
  176.             no recognized errors, close the window.
  177.  
  178.  
  179. Normally the quickfix window is at the bottom of the screen.  If there are
  180. vertical splits, it's at the bottom of the rightmost column of windows.  To
  181. make it always occupy the full width: >
  182.     :botright cwindow
  183. You can move the window around with |window-moving| commands.
  184. For example, to move it to the top: CTRL-W K
  185. The window will mostly keep its height, ignoring 'winheight' and
  186. 'equalalways'.  You can change the height manually (e.g., by dragging the
  187. status line above it with the mouse).
  188.  
  189. In the quickfix window, each line is one error.  The line number is equal to
  190. the error number.  You can use ":.cc" to jump to the error under the cursor.
  191. Hitting the <CR> key or double-clicking the mouse on a line has the same
  192. effect.  The file containing the error is opened in the window above the
  193. quickfix window.  If there already is a window for that file, it is used
  194. instead.  If the buffer in the used window has changed, and the error is in
  195. another file, jumping to the error will fail.  You will first have to make
  196. sure the window contains a buffer which can be abandoned.
  197.  
  198. When the quickfix window has been filled, two autocommand events are
  199. triggered.  First the 'filetype' option is set to "qf", which triggers the
  200. FileType event.  Then the BufReadPost event is triggered.  This can be used to
  201. perform some action on the listed errors.  Example: >
  202.     au BufReadPost quickfix  silent g/^/s//\=line(".")." "/
  203. This prepends the line number to each line.  Note the use of "\=" in the
  204. substitute string of the ":s" command, which is used to evaluate an
  205. expression.
  206.  
  207. Note: Making changes in the quickfix window has no effect on the list of
  208. errors.  'modifiable' is off to avoid making changes.  If you delete or insert
  209. lines anyway, the relation between the text and the error number is messed up.
  210. If you really want to do this, you could write the contents of the quickfix
  211. window to a file and use ":cfile" to have it parsed and used as the new error
  212. list.
  213.  
  214. =============================================================================
  215. 3. Selecting a compiler                    *compiler-select*
  216.  
  217.                             *:comp* *:compiler*
  218. :compiler {name}        Set options to work with compiler {name}.
  219.                 {not available when compiled without the
  220.                 |+eval| feature}
  221.  
  222.  
  223. What this command actually does is:
  224. - delete the "current_compiler" variable
  225. - execute ":runtime! compiler/{name}.vim"
  226.  
  227. For writing a compiler plugin, see |write-compiler-plugin|.
  228.  
  229.  
  230. TEX COMPILER                        *compiler-tex*
  231.  
  232. Included in the distribution compiler for TeX ($VIMRUNTIME/compiler/tex.vim)
  233. is intended to handle all flavors of TeX formats. If b:tex_flavor or
  234. g:tex_flavor (in this precedence) variable exists, it defines TeX flavor for
  235. :make (actually, this is the name of executed command), and if both variables
  236. do not exist, it defaults to "latex". For example, while editing chapter2.tex
  237. \input-ed from mypaper.tex written in AMS-TeX: >
  238.  
  239.     :let b:tex_flavor = 'amstex'
  240.     :compiler tex
  241. <    [editing...] >
  242.     :make mypaper
  243.  
  244. Note that you must specify a name of the file to process as an argument (to
  245. process the right file when editing \input-ed or \include-ed file; portable
  246. solution for substituting % for no arguments is welcome). This is not in the
  247. semantics of make, but you may specify filename without extension ".tex" and
  248. mean this as "make filename.dvi or filename.pdf or
  249. filename.some_result_extension according to compiler"
  250.  
  251. =============================================================================
  252. 4. Using more than one list of errors            *quickfix-error-lists*
  253.  
  254. So far has been assumed that there is only one list of errors.  Actually the
  255. ten last used lists are remembered.  When starting a new list, the previous
  256. ones are automatically kept.  Two commands can be used to access older error
  257. lists.  They set one of the existing error lists as the current one.
  258.  
  259.                         *:colder* *:col* *E380*
  260. :col[der] [count]    Go to older error list.  When [count] is given, do
  261.             this [count] times.  When already at the oldest error
  262.             list, an error message is given.
  263.  
  264.                         *:cnewer* *:cnew* *E381*
  265. :cnew[er] [count]    Go to newer error list.  When [count] is given, do
  266.             this [count] times.  When already at the newest error
  267.             list, an error message is given.
  268.  
  269. When adding a new error list, it becomes the current list.
  270.  
  271. When ":colder" has been used and ":make" or ":grep" is used to add a new error
  272. list, one newer list is overwritten.  This is especially useful if you are
  273. browsing with ":grep" |grep|.  If you want to keep the more recent error
  274. lists, use ":cnewer 99" first.
  275.  
  276. =============================================================================
  277. 5. Using :make                        *:make_makeprg*
  278.  
  279. The ":make" command executes the command given with the 'makeprg' option.
  280. This is done by passing the command to the shell given with the 'shell'
  281. option.  This works almost like typing
  282.  
  283.     ":!{makeprg} [arguments] {shellpipe} {errorfile}".
  284.  
  285. {makeprg} is the string given with the 'makeprg' option.  Any command can be
  286. used, not just "make".  Characters '%' and '#' are expanded as usual on a
  287. command-line.  You can use "#<" to insert the current file name without
  288. extension, for example: >
  289.    :set makeprg=make\ #<.o
  290.  
  291. [arguments] is anything that is typed after ":make".
  292. {shellpipe} is the 'shellpipe' option.
  293. {errorfile} is the 'makeef' option, with ## replaced to make it unique.
  294.  
  295. The placeholder "$*" can be used for the argument list in {makeprog} if the
  296. command needs some additional characters after its arguments.  The $* is
  297. replaced then by all arguments.  Example: >
  298.    :set makeprg=latex\ \\\\nonstopmode\ \\\\input\\{$*}
  299. or simpler >
  300.    :let &mp = 'latex \\nonstopmode \\input\{$*}'
  301. "$*" can be given multiple times, for example: >
  302.    :set makeprg=gcc\ -o\ $*\ $*
  303.  
  304. The 'shellpipe' option defaults to ">" for the Amiga, MS-DOS and Win32.  This
  305. means that the output of the compiler is saved in a file and not shown on the
  306. screen directly.  For Unix "| tee" is used.  The compiler output is shown on
  307. the screen and saved in a file the same time.  Depending on the shell used
  308. "|& tee" or "2>&1| tee" is the default, so stderr output will be included.
  309.  
  310. If 'shellpipe' is empty, the {errorfile} part will be omitted.  This is useful
  311. for compilers that write to an errorfile themselves (Manx's Amiga C).
  312.  
  313. There are some restrictions to the Quickfix mode on the Amiga.  The
  314. compiler only writes the first 25 errors to the errorfile (Manx's
  315. documentation does not say how to get more).  If you want to find the others,
  316. you will have to fix a few errors and exit the editor.  After recompiling,
  317. up to 25 remaining errors will be found.
  318.  
  319. On the Amiga, if Vim was started from the compiler, the :sh and some :!
  320. commands will not work, because Vim is then running in the same process as the
  321. compiler and stdin (standard input) will not be interactive.
  322.  
  323. If you insert or delete lines, mostly the correct error location is still
  324. found because hidden marks are used (Manx's Z editor does not do this).
  325. Sometimes, when the mark has been deleted for some reason, the message "line
  326. changed" is shown to warn you that the error location may not be correct.  If
  327. you quit Vim and start again the marks are lost and the error locations may
  328. not be correct anymore.
  329.  
  330. =============================================================================
  331. 6. The error file format                *error-file-format*
  332.  
  333. A template for the errorfile name can be set with the 'makeef' option.  If it
  334. includes "##", Vim will replace this with a number to make it a unique name.
  335.  
  336. The format of the file from the Aztec compiler is:
  337.  
  338.     filename>linenumber:columnnumber:errortype:errornumber:errormessage
  339.  
  340.     filename    name of the file in which the error was detected
  341.     linenumber    line number where the error was detected
  342.     columnnumber    column number where the error was detected
  343.     errortype    type of the error, normally a single 'E' or 'W'
  344.     errornumber    number of the error (for lookup in the manual)
  345.     errormessage    description of the error
  346.  
  347.                     *errorformat* *E372* *E373* *E374*
  348.                         *E375* *E376* *E377* *E378*
  349. Another compiler is likely to use a different format.  You should set the
  350. 'errorformat' option to a scanf-like string that describes the format.
  351. First, you need to know how scanf works.  Look in the documentation of your
  352. C compiler.  Vim will understand the following conversion characters.
  353. Others are invalid.
  354.     %f        file name (finds a string)
  355.     %l        line number (finds a number)
  356.     %c        column number (finds a number representing character
  357.             column of the error, (1 <tab> == 1 character column))
  358.     %v        virtual column number (finds a number representing
  359.             screen column of the error (1 <tab> == 8 screen
  360.             columns)
  361.     %t        error type (finds a single character)
  362.     %n        error number (finds a number)
  363.     %m        error message (finds a string)
  364.     %r        matches the "rest" of a single-line file message %O/P/Q
  365.     %p        pointer line (finds a sequence of '-', '.' or ' ' and
  366.             uses the length for the column number)
  367.     %*{conv}    any scanf non-assignable conversion
  368.     %%        the single '%' character
  369.  
  370. The following uppercase conversion characters specify the type of special
  371. format strings.  At most one of them may be given as a prefix at the begin
  372. of a single comma-separated format pattern.
  373. Some compilers produce messages that consist of directory names that have to
  374. be prepended to each file name read by %f (example: GNU make). The following
  375. codes can be used to scan these directory names; they will be stored in an
  376. internal directory stack.                    *E379*
  377.     %D        "enter directory" format string; expects a following
  378.               %f that finds the directory name
  379.     %X        "leave directory" format string; expects following %f
  380.  
  381.                         *errorformat-multi-line*
  382. It is possible to read the output of programs that produce multi-line messages,
  383. ie. error strings that consume more than one line. Possible prefixes are:
  384.     %A        start of a multi-line message (unspecified type)
  385.     %E        start of a multi-line error message
  386.     %W        start of a multi-line warning message
  387.     %I        start of a multi-line informational message
  388.     %C        continuation of a multi-line message
  389.     %Z        end of a multi-line message
  390.     %G        global; useful only in conjunction with '+' or '-'
  391.     %O        single-line file message: overread the matched part
  392.     %P        single-line file message: push file %f onto the stack
  393.     %Q        single-line file message: pop the last file from stack
  394. The codes '+' or '-' can be combined with the uppercase codes above; in that
  395. case they have to precede the letter, eg. '%+A' or '%-G':
  396.     %-        do not include the matching multi-line in any output
  397.     %+        include the whole matching line in the %m error string
  398.  
  399. The scanf()-like "%*[]" notation is supported for backward-compatibility
  400. with previous versions of Vim.  However, it is also possible to specify
  401. (nearly) any Vim supported regular expression in format strings.
  402. Since meta characters of the regular expression language can be part of
  403. ordinary matching strings or file names (and therefore internally have to
  404. be escaped), meta symbols have to be written with leading '%':
  405.     %\        the single '\' character. Note that this has to be
  406.             escaped ("%\\") in ":set errorformat=" definitions.
  407.     %.        the single '.' character.
  408.     %#        the single '*'(!) character.
  409.     %^        the single '^' character.
  410.     %$        the single '$' character.
  411.     %[        the single '[' character for a [] character range.
  412.     %~        the single '~' character.
  413. When using character classes in expressions (see |/\i| for an overview),
  414. terms containing the "\+" quantifier can be written in the scanf() "%*"
  415. notation. Example: "%\\d%\\+" ("\d\+", "any number") is equivalent to "%*\\d".
  416. Important note: The \(...\) grouping of sub-matches can not be used in format
  417. specifications because it is reserved for internal conversions.
  418.  
  419. note: By default the difference between upper and lowercase is ignored.  If
  420. you want to match case, add "\C" to the pattern |/\C|.
  421.  
  422. Some examples for C compilers that produce single-line error outputs:
  423. %f>%l:%c:%t:%n:%m"            for the AztecC.Err file
  424. %f:%l:\ %t%*[^0123456789]%n:\ %m    for Manx/Aztec C error messages
  425.                     (scanf() doesn't understand [0-9])
  426. %f\ %l\ %t%*[^0-9]%n:\ %m        for SAS C
  427. \"%f\"\\,%*[^0-9]%l:\ %m        for generic C compilers
  428. %f:%l:\ %m                for GCC
  429. %f:%l:\ %m,%Dgmake[%*\\d]:\ Entering\ directory\ `%f',
  430. %Dgmake[%*\\d]:\ Leaving\ directory\ `%f'
  431.                     for GCC with gmake (concat the lines!)
  432. %f(%l)\ :\ %*[^:]:\ %m            old SCO C compiler (pre-OS5)
  433. %f(%l)\ :\ %t%*[^0-9]%n:\ %m        idem, with error type and number
  434. %f:%l:\ %m,In\ file\ included\ from\ %f:%l:,\^I\^Ifrom\ %f:%l%m
  435.                     for GCC, with some extras
  436.  
  437. Extended examples for the handling of multi-line messages are given below,
  438. see |errorformat-Jikes| and |errorformat-LaTeX|.
  439.  
  440. Note the backslash in front of a space and double quote.  It is required for
  441. the :set command.  There are two backslashes in front of a comma, one for the
  442. :set command and one to avoid recognizing the comma as a separator of error
  443. formats.
  444.  
  445. The "%f" conversion depends on the current 'isfname' setting.
  446.  
  447. The "%f" and "%m" conversions have to detect the end of the string.  They
  448. should be followed by a character that cannot be in the string.  Everything
  449. up to that character is included in the string.  But when the next character
  450. is '%' or a backslash, "%f" will look for any 'isfname' character and "%m"
  451. finds anything.  If the "%f" or "%m" is at the end, everything up to the end
  452. of the line is included.
  453.  
  454. On MS-DOS, MS-Windows and OS/2 a leading "C:" will be included in "%f", even
  455. when using "%f:".  This means that a file name which is a single alphabetical
  456. letter will not be detected.
  457.  
  458. The "%p" conversion is normally followed by a "^".  It's used for compilers
  459. that output a line like: >
  460.             ^
  461. or >
  462.    ---------^
  463. to indicate the column of the error.  This is to be used in a multi-line error
  464. message.  See |errorformat-javac| for a  useful example.
  465.  
  466.  
  467. When defining an "enter directory" or "leave directory" format, the "%D" or
  468. "%X" has to be given at the start of that substring. Vim tracks the directory
  469. changes and prepends the current directory to each erroneous file found with a
  470. relative path.  See |quickfix-directory-stack| for details, tips and
  471. limitations.
  472.  
  473. To be able to detect output from several compilers, several format patterns
  474. may be put in 'errorformat', separated by commas (note: blanks after the comma
  475. are ignored).  The first pattern that has a complete match is used.  If no
  476. match is found, matching parts from the last one will be used, although the
  477. file name is removed and the error message is set to the whole message.  If
  478. there is a pattern that may match output from several compilers (but not in a
  479. right way), put it after one that is more restrictive.  To include a comma in
  480. a pattern precede it with a backslash (you have to type two in a set command).
  481. To include a backslash itself give two backslashes (you have to type four in a
  482. set command).
  483.  
  484.                             *quickfix-valid*
  485. If a line is detected that does not completely match the 'errorformat', the
  486. whole line is put in the error message and the entry is marked "not valid"
  487. These lines are skipped with the ":cn" and ":cp" commands (unless there is
  488. no valid line at all).  You can use ":cl!" to display all the error messages.
  489.  
  490. If the error format does not contain a file name Vim cannot switch to the
  491. correct file.  You will have to do this by hand.
  492.  
  493. If you have a compiler that produces error messages that do not fit in the
  494. format string, you could write a program that translates the error messages
  495. into this format.  You can use this program with the ":make" command by
  496. changing the 'makeprg' option.  For example: >
  497.    :set mp=make\ \\\|&\ error_filter
  498. The backslashes before the pipe character are required to avoid it to be
  499. recognized as a command separator.  The backslash before each space is
  500. required for the set command.
  501.  
  502. =============================================================================
  503. 7. The directory stack                *quickfix-directory-stack*
  504.  
  505. Quickfix maintains a stack for saving all used directories parsed from the
  506. make output. For GNU-make this is rather simple, as it always prints the
  507. absolute path of all directories it enters and leaves. Regardless if this is
  508. done via a 'cd' command in the makefile or with the parameter "-C dir" (change
  509. to directory before reading the makefile). It may be useful to use the switch
  510. "-w" to force GNU-make to print out the working directory before and after
  511. processing.
  512.  
  513. Maintaining the correct directory is more complicated if you don't use
  514. GNU-make. AIX-make for example doesn't print any information about its working
  515. directory. Then you need to enhance the makefile. In the makefile of lesstiff
  516. their is a command which echos "Making {target} in {dir}". The special problem
  517. here is that it doesn't print informations on leaving the directory and that
  518. it doesn't print the absolute path.
  519.  
  520. To solve the problem with relative paths and missing "leave directory"
  521. messages Vim uses following algorithm:
  522.  
  523. 1) Check if the given directory is a subdirectory of the current directory.
  524.    If this is true, store it as the current directory.
  525. 2) If it is not a subdir of the current directory, try if this is a
  526.    subdirectory of one of the upper directories.
  527. 3) If the directory still isn't found, it is assumed to be a subdirectory
  528.    of Vim's current directory.
  529.  
  530. Additionally it is checked for every file, if it really exists in the
  531. identified directory.  If not, it is searched in all other directories of the
  532. directory stack (NOT the directory subtree!). If it is still not found, it is
  533. assumed that it is in Vim's current directory.
  534.  
  535. There are limitation in this algorithm. This examples assume that make just
  536. prints information about entering a directory in the form "Making all in dir".
  537.  
  538. 1) Assume you have following directories and files:
  539.    ./dir1
  540.    ./dir1/file1.c
  541.    ./file1.c
  542.  
  543.    If make processes the directory "./dir1" before the current directory and
  544.    there is an error in the file "./file1.c", you will end up with the file
  545.    "./dir1/file.c" loaded by Vim.
  546.  
  547.    This can only be solved with a "leave directory" message.
  548.  
  549. 2) Assume you have following directories and files:
  550.    ./dir1
  551.    ./dir1/dir2
  552.    ./dir2
  553.  
  554.    You get the following:
  555.  
  556.    Make output              Directory interpreted by Vim
  557.    ------------------------      ----------------------------
  558.    Making all in dir1          ./dir1
  559.    Making all in dir2          ./dir1/dir2
  560.    Making all in dir2          ./dir1/dir2
  561.  
  562.    This can be solved by printing absolute directories in the "enter directory"
  563.    message or by printing "leave directory" messages..
  564.  
  565. To avoid this problems, ensure to print absolute directory names and "leave
  566. directory" messages.
  567.  
  568. Examples for Makefiles:
  569.  
  570. Unix:
  571.     libs:
  572.         for dn in $(LIBDIRS); do                \
  573.         (cd $$dn; echo "Entering dir '$$(pwd)'"; make); \
  574.         echo "Leaving dir";                \
  575.         done
  576.  
  577. Add
  578.     %DEntering\ dir\ '%f',%XLeaving\ dir
  579. to your 'errorformat' to handle the above output.
  580.  
  581. Note that Vim doesn't check if the directory name in a "leave directory"
  582. messages is the current directory. This is why you could just use the message
  583. "Leaving dir".
  584.  
  585. =============================================================================
  586. 8. Specific error file formats            *errorformats*
  587.  
  588.                         *errorformat-Jikes*
  589. Jikes(TM), a source-to-bytecode Java compiler published by IBM Research,
  590. produces simple multi-line error messages.
  591.  
  592. An 'errorformat' string matching the produced messages is shown below.
  593. The following lines can be placed in the user's |vimrc| to overwrite Vim's
  594. recognized default formats, or see |:set+=| how to install this format
  595. additionally to the default. >
  596.  
  597.   :set efm=%A%f:%l:%c:%*\\d:%*\\d:,
  598.     \%C%*\\s%trror:%m,
  599.     \%+C%*[^:]%trror:%m,
  600.     \%C%*\\s%tarning:%m,
  601.     \%C%m
  602. <
  603. Jikes(TM) produces a single-line error message when invoked with the option
  604. "+E", and can be matched with the following: >
  605.  
  606.   :set efm=%f:%l:%v:%*\\d:%*\\d:%*\\s%m
  607. <
  608.                         *errorformat-javac*
  609. This 'errorformat' has been reported to work well for javac, which outputs a
  610. line with "^" to indicate the column of the error: >
  611.   :set efm=%A%f:%l:\ %m,%-Z%p^,%-C%.%#
  612. <
  613.                         *errorformat-ant*
  614. For ant (http://jakarta.apache.org/) the above errorformat has to be modified
  615. to honour the leading [javac] in front of each javac output line: >
  616.   :set efm=%A\ %#[javac]\ %f:%l:\ %m,%-Z\ %#[javac]\ %p^,%-C%.%#
  617.  
  618. The 'errorformat' can also be configured to handle ant together with either
  619. javac or jikes.  If you're using jikes, you should tell ant to use jikes' +E
  620. command line switch which forces jikes to generate one-line error messages.
  621. This is what the second line (of a build.xml file) below does: >
  622.   <property name = "build.compiler"       value = "jikes"/>
  623.   <property name = "build.compiler.emacs" value = "true"/>
  624.  
  625. The 'errorformat' which handles ant with both javac and jikes is: >
  626.   :set efm=\ %#[javac]\ %#%f:%l:%c:%*\\d:%*\\d:\ %t%[%^:]%#:%m,
  627.        \%A\ %#[javac]\ %f:%l:\ %m,%-Z\ %#[javac]\ %p^,%-C%.%#
  628. <
  629.                         *errorformat-jade*
  630. parsing jade (see http://www.jclark.com/) errors is simple: >
  631.   :set efm=jade:%f:%l:%c:%t:%m
  632. <
  633.                         *errorformat-LaTeX*
  634. The following is an example how an 'errorformat' string can be specified
  635. for the (La)TeX typesetting system which displays error messages over
  636. multiple lines.  The output of ":clist" and ":cc" etc. commands displays
  637. multi-lines in a single line, leading white space is removed.
  638. It should be easy to adopt the above LaTeX errorformat to any compiler output
  639. consisting of multi-line errors.
  640.  
  641. The commands can be placed in a |vimrc| file or some other Vim script file,
  642. eg. a script containing LaTeX related stuff which is loaded only when editing
  643. LaTeX sources.
  644. Make sure to copy all lines of the example (in the given order), afterwards
  645. remove the comment lines.  For the '\' notation at the start of some lines see
  646. |line-continuation|.
  647.  
  648.         First prepare 'makeprg' such that LaTeX will report multiple
  649.         errors; do not stop when the first error has occurred: >
  650.  :set makeprg=latex\ \\\\nonstopmode\ \\\\input\\{$*}
  651. <
  652.         Start of multi-line error messages: >
  653.  :set efm=%E!\ LaTeX\ %trror:\ %m,
  654.     \%E!\ %m,
  655. <        Start of multi-line warning messages; the first two also
  656.         include the line number. Meaning of some regular expressions:
  657.           - "%.%#"  (".*")   matches a (possibly empty) string
  658.           - "%*\\d" ("\d\+") matches a number >
  659.     \%+WLaTeX\ %.%#Warning:\ %.%#line\ %l%.%#,
  660.     \%+W%.%#\ at\ lines\ %l--%*\\d,
  661.     \%WLaTeX\ %.%#Warning:\ %m,
  662. <        Possible continuations of error/warning messages; the first
  663.         one also includes the line number: >
  664.     \%Cl.%l\ %m,
  665.     \%+C\ \ %m.,
  666.     \%+C%.%#-%.%#,
  667.     \%+C%.%#[]%.%#,
  668.     \%+C[]%.%#,
  669.     \%+C%.%#%[{}\\]%.%#,
  670.     \%+C<%.%#>%.%#,
  671.     \%C\ \ %m,
  672. <        Lines that match the following patterns do not contain any
  673.         important information; do not include them in messages: >
  674.     \%-GSee\ the\ LaTeX%m,
  675.     \%-GType\ \ H\ <return>%m,
  676.     \%-G\ ...%.%#,
  677.     \%-G%.%#\ (C)\ %.%#,
  678.     \%-G(see\ the\ transcript%.%#),
  679. <        Generally exclude any empty or whitespace-only line from
  680.         being displayed: >
  681.     \%-G\\s%#,
  682. <        The LaTeX output log does not specify the names of erroneous
  683.         source files per line; rather they are given globally,
  684.         enclosed in parentheses.
  685.         The following patterns try to match these names and store
  686.         them in an internal stack.  The patterns possibly scan over
  687.         the same input line (one after another), the trailing "%r"
  688.         conversion indicates the "rest" of the line that will be
  689.         parsed in the next go until the end of line is reached.
  690.  
  691.         Overread a file name enclosed in '('...')'; do not push it
  692.         on a stack since the file apparently does not contain any
  693.         error: >
  694.     \%+O(%f)%r,
  695. <        Push a file name onto the stack. The name is given after '(': >
  696.     \%+P(%f%r,
  697.     \%+P\ %\\=(%f%r,
  698.     \%+P%*[^()](%f%r,
  699.     \%+P[%\\d%[^()]%#(%f%r,
  700. <        Pop the last stored file name when a ')' is scanned: >
  701.     \%+Q)%r,
  702.     \%+Q%*[^()])%r,
  703.     \%+Q[%\\d%*[^()])%r
  704.  
  705. Note that in some cases file names in the LaTeX output log cannot be parsed
  706. properly.  The parser might have been messed up by unbalanced parentheses
  707. then.  The above example tries to catch the most relevant cases only.
  708. You can customize the given setting to suit your own purposes, for example,
  709. all the annoying "Overfull ..." warnings could be excluded from being
  710. recognized as an error.
  711. Alternatively to filtering the LaTeX compiler output, it is also possible
  712. to directly read the *.log file that is produced by the [La]TeX compiler.
  713. This contains even more useful information about possible error causes.
  714. However, to properly parse such a complex file, an external filter should
  715. be used.  See the description further above how to make such a filter known
  716. by Vim.
  717.  
  718.                         *errorformat-Perl*
  719. In $VIMRUNTIME/tools you can find the efm_perl.pl script, which filters Perl
  720. error messages into a format that quickfix mode will understand.  See the
  721. start of the file about how to use it.
  722.  
  723.  
  724.  
  725.  vim:tw=78:ts=8:ft=help:norl:
  726.